import React, { Component } from 'react';
import { glabalContext } from './globlData.js'
const { Consumer } = glabalContext
class childGrandson extends Component {
  state = {}
  render () {
    return (<>
      <h2>孙子组件</h2>
      <Consumer>
        {value => (
          <div>
            <p>孙子组件需要手机号</p>
            <p>全局：{value.tel}</p>
            <p>父组件本身：{value.userInfo.name}</p>
            <button onClick={()=>value.updateTel('15175414998')}>孙子组件修改全局手机号</button>
          </div>
        )}
      </Consumer>
    </>);
  }
}

export default childGrandson;